import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, UpdateDateColumn } from 'typeorm';

@Entity('user')
export class User {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ unique: true, comment: '用户账号' })
  username: string;

  @Column({ comment: '用户密码（bcrypt加密）' })
  password: string;

  @Column({ nullable: true, comment: '账号名称' })
  accountname: string;

  @Column({ nullable: true, comment: '用户头像图片URL' })
  userImage?: string;

  @Column({ default: true, comment: '账号状态（true：启用，false：禁用）' })
  isEnabled: boolean;

  @Column({ default: false, comment: '是否记住账号密码' })
  rememberMe: boolean;

  // 找回密码/登录扩展字段
  @Column({ nullable: true, comment: '绑定手机号' })
  phone?: string;

  @Column({ nullable: true, comment: '绑定邮箱' })
  email?: string;

  @Column({ nullable: true, comment: '密码重置验证码' })
  resetCode?: string;

  @Column({ nullable: true, comment: '验证码过期时间' })
  resetCodeExpire?: Date;

  @Column({ nullable: true, comment: '当前登录token（用于退出登录）' })
  currentToken?: string;

  @CreateDateColumn({ comment: '创建时间' })
  createdAt: Date;

  @UpdateDateColumn({ comment: '更新时间' })
  updatedAt: Date;
}